<!--
 * @Description:
 * @Author: cgt
 * @Date: 2021-12-23 14:05:56
 * @LastEditors: cgt
 * @LastEditTime: 2021-12-28 19:55:51
-->
<template>
  <div>
    <el-button v-for="(action, index) in actions" :key="index" @click="doAction(action)">{{
      action.name || action.key
    }}</el-button>
  </div>
</template>

<script>
import mixins from '../mixins';
export default {
  name: 'BaseMapTool',
  props: {
    getTool: {
      type: Function,
      required: true
    }
  },
  mixins: [mixins],
  data() {
    return {
      actions: [
        {
          key: 'getBounds'
        },
        {
          key: 'fitBounds',
          params: [116.88766479503897, 24.593334055901682, 118.27468872081703, 25.77145055234946]
        },
        {
          key: 'getCenter'
        },
        {
          key: 'centerAt',
          params: [111.00585937513067, 27.561851782987127]
        },
        {
          key: 'panLeft'
        },
        {
          key: 'panRight'
        },
        {
          key: 'panUp'
        },
        {
          key: 'panDown'
        },
        {
          key: 'zoomIn'
        },
        {
          key: 'zoomOut'
        },
        {
          key: 'getZoom'
        },
        {
          key: 'setZoom',
          params: 8
        },
        {
          key: 'setDefaultStyle',
          name: '矢量图层'
        },
        {
          key: 'setLightStyle',
          name: '浅色图层'
        },
        {
          key: 'setDarkStyle',
          name: '深色图层'
        },
        {
          key: 'setSatelliteStyle',
          name: '卫星图层'
        }
      ]
    };
  },
  methods: {
    doAction(action) {
      var result = this.getTool('BaseMapTool')[action.key](action.params);
      console.log(result);
    }
  }
};
</script>

<style scoped></style>
